<?	
	/* Se asegura que el archivo es incluido por el index */
	defined( 'LOAD_MODULE_ACTION' ) or die( 'No esta permitido el acceso directo a ' . __FILE__ );  
		$this->oTmpObject = new Tarea_registro_frm( $this );
	
	class Tarea_registro_frm extends Frm
	{
	function setValue ( $ncTarea, $ncRegistro )
		{
			$cSql = "SELECT  ncPersona,  nqHoras,  dRegistro,  cObservacion
				FROM atTareaRegistro
				WHERE ncTarea = '$ncTarea' AND  ncRegistro = '$ncRegistro' ";
			$aDatos = $this->oDatabase->getArray($cSql);	
			$this->setFieldsArray ( $aDatos );
		}
	function Tarea_registro_frm( &$oModule )
		{
			$this->Frm( $oModule );
			//Crea los Objetos de los campos de edicion
			$this->aFields['ncTarea']			= new InputList( "Tarea", "ncTarea" );
			$this->aFields['ncRegistro']		= new Input( "Codigo", "ncRegistro", '', false, true );
			$this->aFields['ncPersona']		= new InputList( "Persona", "ncPersona" );
			$this->aFields['nqHoras']			= new InputNumber( "Horas", "nqHoras" );
			$this->aFields['dRegistro']		= new InputDate( "Fecha", "dRegistro" );
			$this->aFields['cObservacion']	= new InputText( "Observaciones", "cObservacion" );	
		}	
	function initializeForm()
		{
			// Si viene el Ubicacion hace el retrieve
				if ( $this->isRetrievable() && $this->aFields['ncTarea']->getValue() && $this->aFields['ncRegistro']->getValue() )
				{
					$this->setValue( $this->aFields['ncTarea']->getValue(), $this->aFields['ncRegistro']->getValue() );
				}
			// Configura el Titulo
				$this->setLabel( "Registros" );	
			return true;
		}
	function initializeField( $cField , &$oField )
		{			
			switch ( $cField )
			{
					case 'ncTarea':
						if ( $oField->getValue() ) 
							$oField->setHidden();
						else
						{
							$cSql = "SELECT ncTarea, cdTarea FROM atTarea";
							$oField->setMatrix($this->oDatabase->getMatrix($cSql));
							$oField->setMandatory($this->isMandatory());
						}
					break;
					case 'ncPersona':
						$ncTarea = $this->aFields['ncTarea']->getValue();
						if ( $ncTarea )
						{
							$cResponsables = implode(',', $this->oDatabase->getArray("SELECT ncPersona FROM atTareaResponsable WHERE ncTarea=$ncTarea") ); 
							$cSql = "SELECT ncPersona, cNombre, cApellido  FROM atPersona WHERE ncPersona in ( $cResponsables ) ";
							$oField->setColDescriptionMatrix( array(1,2) );
							$oField->setMatrix($this->oDatabase->getMatrix($cSql));
							$oField->setMandatory($this->isMandatory());
						} else $oField->setHidden();
					break;
					case 'nqHoras':
						$oField->setMandatory($this->isMandatory());
					break;
					case 'dRegistro':
						$oField->setDefault(Date("Y-m-d"));
					break;
					case 'cObservacion':
						$oField->setEditor();
					break;
			}
 		}
	}
?>